<?php
if( !defined('IN_INDEX') )
{
	die('This page is hidden.');
}

if(!checkSession())
{
			function redirect($url)
			{
			?>
				<script type="text/javascript">
					{
					window.location = "<?=$url?>";
					}
				</script>
			<?php 
			}
			redirect("index.php?action=profile&sub=edit");
	exit;
}else{
	if(isset($_REQUEST['id']))
	{
		$USER_PROFILE = new User('id', $_REQUEST['id']);
		$page_url = "index.php?action=profile&id=" . $_REQUEST['id'] . "&sub=stats";
	}
	else
	{
		$USER_PROFILE = $USER;
		$page_url = "index.php?action=profile&sub=stats";
	}
}
include('inc/functions_award.php');
include('inc/functions_blog.php');

?>
<script type="text/javascript">
function submitform(){
	if(confirm('<?php echo translate('deleteawardwarning')?>')){
		return true;
	}else{
		return false;
	}
}
</script>
<?php
	if(isset($_POST['deleteAward'])){
		if(isset($_POST['awardDeleteId'])){
			$awardDeleteIdList = $_POST['awardDeleteId'];
			if(count($awardDeleteIdList) >0){
				$awardDeleteIdListStr = "";
				foreach ($awardDeleteIdList as $awardIdTemp){
					$awardDeleteIdListStr .= $awardIdTemp.",";
				}
				$awardDeleteIdListStr = substr($awardDeleteIdListStr, 0, strlen($awardDeleteIdListStr) - 1);
				deleteAward($awardDeleteIdListStr);
			}
		}
	}

?>
<div id='postpath'>
	<a title="<?php echo translate('gotofrontpage'); ?>" href="index.php"><?php echo translate('home'); ?></a>
	 &gt; <a href="index.php?action=blogs" title='<?php echo translate('showallblogs'); ?>'><?php echo translate('blog'); ?></a> 
	 &gt; <a href="index.php?action=profile&id=<?php echo $USER_PROFILE->getId(); ?>"><?php echo ucf($USER_PROFILE->getFirstname()) . " " . ucf($USER_PROFILE->getLastname()); ?></a>
	&gt; <a href="index.php?action=profile&sub=stats&id=<?php echo $USER_PROFILE->getId(); ?>" title='<?php echo translate('stats'); ?>'><?php echo translate('stats'); ?></a>
	&gt; <a href="index.php?action=profile&sub=stats_awards&id=<?php echo $USER_PROFILE->getId(); ?>" title='<?php echo translate('awards'); ?>'><?php echo translate('awards'); ?></a>
</div>
<h1><?php echo translate('awards'); ?></h2> &nbsp;&nbsp;&nbsp;<a class="view-all-award-link" href="index.php?action=profile&sub=awardlist" style="font-size: 14px; color: #000000;">List avaiable awards</a>
<div class="award-list" style="text-align: center; color: red;">
<?php
	$awardList = getAllAward();
	if(count($awardList) > 0){
		while($awardItem = mysql_fetch_array($awardList)) 
		{
			$result = getAwardOfExercise($_SESSION['user_id'], $awardItem);
			if($result){
?>
	<div class="award-item" style="margin: 15px 0px 0px 20px; float: left;">
		<?php
		if(isset($result['training_id'])){
		?>
		<a href="index.php?action=profile&sub=show&tid=<?php echo $result['training_id']?>">
		<img src="img/award_pic/<?php echo $awardItem['image'] ?>"/><br/>
		<span class="award-name"><?php echo $awardItem['award_name']."<br/>"; ?></span>
		</a>
		<?php
		}else{
		?>
		<img src="img/award_pic/<?php echo $awardItem['image'] ?>"/><br/>
		<span class="award-name"><?php echo $awardItem['award_name']."<br/>"; ?></span>
		<?php
		}
		?>
		<a href="index.php?action=profile&sub=show&tid=<?php echo $result['training_id']?>">
		<?php if(is_numeric($result['date'])){echo date("m-d-Y", $result['date']);}?>
		</a>
	</div>
<?php
			}
		}
	}
?>
</div>
<div style="clear:both;"></div>
 